﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using log4net;

namespace SapB1WebApp.Utils
{
    public static class Log
    {
        private static ILog _log;

        public static string LogFormat
        {
            get { return Environment.NewLine + "ErrorCode: {0} " + Environment.NewLine + "Function: {1} " + Environment.NewLine + "Detail: {2} "; }
        }

        public static void WriteException(Type context, string errorCode, Exception ex)
        {
            _log = LogManager.GetLogger(context);
            _log.Error(errorCode, ex);
        }

        public static void WriteError(Type context, string methodName, string code, string detail)
        {
            _log = LogManager.GetLogger(context);
            _log.ErrorFormat(LogFormat, code, methodName, detail);
        }

        public static void WriteInfo(Type context, string code, string methodName, string detail)
        {
            _log = LogManager.GetLogger(context);
            _log.InfoFormat(LogFormat, code, methodName, detail);
        }
    }
}